package com.lyluly.coursemgmt.servicemodule.iService.serviceImpl;

import com.lyluly.coursemgmt.servicemodule.iDao.PushClickMapper;
import com.lyluly.coursemgmt.servicemodule.iService.IPushClickService;
import com.lyluly.coursemgmt.servicemodule.model.PushClick;
import com.lyluly.coursemgmt.servicemodule.model.PushClickExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PushClickServiceImpl implements IPushClickService {
    @Autowired
    private PushClickMapper pushClickMapper;

    public void addPushClick(PushClick pushClick) {
        pushClick.setCreatetime(new Date());
        pushClickMapper.insert(pushClick);
    }

    public void modifyPushClick(PushClick pushClick) {
        pushClickMapper.updateByPrimaryKeySelective(pushClick);
    }

    public void removePushClick(int pushClickId) {
        pushClickMapper.deleteByPrimaryKey(pushClickId);
    }

    public PushClick findPushClickById(int pushClickId) {
        return pushClickMapper.selectByPrimaryKey(pushClickId);
    }

    public List<PushClick> findPushClickList() {
        return pushClickMapper.selectByExample(null);
    }

    public List<PushClick> findPushClickListByPushId(int pushId) {
        PushClickExample pushClickExample = new PushClickExample();
        pushClickExample.or().andPushIdEqualTo(pushId);
        return pushClickMapper.selectByExample(pushClickExample);
    }

    public List<PushClick> findPushClickListBySId(String sId) {
        PushClickExample pushClickExample = new PushClickExample();
        pushClickExample.or().andSIdEqualTo(sId);
        return pushClickMapper.selectByExample(pushClickExample);
    }
}
